// EmbededBrowserUIHandler.h : Declaration of the CEmbededBrowserUIHandler

#pragma once
#include "resource.h"       // main symbols



#include "MySearch.h"



#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif

using namespace ATL;


// CEmbededBrowserUIHandler

class ATL_NO_VTABLE CEmbededBrowserUIHandler :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CEmbededBrowserUIHandler, &CLSID_EmbededBrowserUIHandler>,
	public IDispatchImpl<IEmbededBrowserUIHandler, &IID_IEmbededBrowserUIHandler, &LIBID_MySearchLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
	CComQIPtr<IDispatch> m_spExtDispatch;
public:
	CEmbededBrowserUIHandler()
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_EMBEDEDBROWSERUIHANDLER)


BEGIN_COM_MAP(CEmbededBrowserUIHandler)
	COM_INTERFACE_ENTRY(IEmbededBrowserUIHandler)
	COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()



	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
	// Do not show the context menu
	STDMETHOD (ShowContextMenu) ( 
		/* [in] */ DWORD dwID,
		/* [in] */ DWORD x,
		/* [in] */ DWORD y,
		/* [in] */ IUnknown  *pcmdtReserved,
		/* [in] */ IDispatch *pdispReserved,
		/* [retval][out] */ HRESULT  *dwRetVal)
	{
		*dwRetVal = S_FALSE;
		return S_FALSE;
	}

	// Mark all the other methods as not implemented

	STDMETHOD (GetHostInfo) ( 
		/* [out][in] */ DWORD  *pdwFlags,
		/* [out][in] */ DWORD  *pdwDoubleClick)
	{
		*pdwFlags = DOCHOSTUIFLAG_NO3DBORDER| DOCHOSTUIFLAG_SCROLL_NO;
		*pdwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
		return S_OK;
	}


	STDMETHOD (ShowUI) ( 
		/* [in] */ DWORD dwID,
		/* [in] */ IUnknown  *pActiveObject,
		/* [in] */ IUnknown  *pCommandTarget,
		/* [in] */ IUnknown  *pFrame,
		/* [in] */ IUnknown  *pDoc,
		/* [retval][out] */ HRESULT  *dwRetVal)
	{

		return E_NOTIMPL;
	}


	STDMETHOD (HideUI) (void)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (UpdateUI) (void)
	{
		return E_NOTIMPL;
	}

	STDMETHOD (EnableModeless) ( 
		/* [in] */ VARIANT_BOOL fEnable)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (OnDocWindowActivate) ( 
		/* [in] */ VARIANT_BOOL fActivate)
	{
		CString str;
		str.Format(" active state :%s\n",fActivate ? _T("Active") : _T("NoActive"));
		OutputDebugString(str);
		return E_NOTIMPL;
	}


	STDMETHOD (OnFrameWindowActivate) ( 
		/* [in] */ VARIANT_BOOL fActivate)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (ResizeBorder) ( 
		/* [in] */ long left,
		/* [in] */ long top,
		/* [in] */ long right,
		/* [in] */ long bottom,
		/* [in] */ IUnknown  *pUIWindow,
		/* [in] */ VARIANT_BOOL fFrameWindow)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (TranslateAccelerator) ( 
		/* [in] */ DWORD hWnd,
		/* [in] */ DWORD nMessage,
		/* [in] */ DWORD wParam,
		/* [in] */ DWORD lParam,
		/* [in] */ BSTR bstrGuidCmdGroup,
		/* [in] */ DWORD nCmdID,
		/* [retval][out] */ HRESULT  *dwRetVal)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (GetOptionKeyPath) ( 
		/* [out] */ BSTR  *pbstrKey,
		/* [in] */ DWORD dw)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (GetDropTarget) ( 
		/* [in] */ IUnknown  *pDropTarget,
		/* [out] */ IUnknown  **ppDropTarget)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (GetExternal) ( 
		/* [out] */ IDispatch  **ppDispatch)
	{
		return m_spExtDispatch.CopyTo (ppDispatch);
	}


	STDMETHOD (TranslateUrl) ( 
		/* [in] */ DWORD dwTranslate,
		/* [in] */ BSTR bstrURLIn,
		/* [out] */ BSTR  *pbstrURLOut)
	{
		return E_NOTIMPL;
	}


	STDMETHOD (FilterDataObject) ( 
		/* [in] */ IUnknown  *pDO,
		/* [out] */ IUnknown  **ppDORet)
	{
		return E_NOTIMPL;
	}



};

OBJECT_ENTRY_AUTO(__uuidof(EmbededBrowserUIHandler), CEmbededBrowserUIHandler)
